<html>
<head><meta charset="utf-8"><title>rust-analyzer is slow :-( · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html">rust-analyzer is slow :-(</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="166121287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166121287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166121287">(May 20 2019 at 21:27)</a>:</h4>
<p>I've finally wrapped up my course about Rust, so I have more time to hack on the analyzer.</p>
<p>I am doing some refactorings now, and observing that it is pretty slow. Will hopefully look into that. I have three hypothesis:</p>
<ul>
<li>chalk is slow</li>
<li>macros are slow</li>
<li>either 1 or 2 is true, and, in addition, we do something stupid in the langauge server, like recomputing diagnostics multiple times</li>
</ul>



<a name="166122130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166122130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166122130">(May 20 2019 at 21:40)</a>:</h4>
<p>The diagnostics thing is definitely real. I've also noticed sometimes that things get so bad it hangs up new line insertion.</p>



<a name="166122248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166122248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166122248">(May 20 2019 at 21:42)</a>:</h4>
<p>And this is the third hypothesis: slow diagnostics shouldn't block interactive features...</p>
<p>I wonder what's the best way to design for that? I guess, in the main loop, we should have two thread pools:</p>
<ul>
<li>one for low-priority cancelable background tasks</li>
<li>one for top-priority interactive calls</li>
</ul>



<a name="166147816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166147816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166147816">(May 21 2019 at 07:09)</a>:</h4>
<p>I think Chalk integration is at least a big part of it, and I think I'll switch it to my fuel branch</p>



<a name="166148625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166148625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166148625">(May 21 2019 at 07:26)</a>:</h4>
<p>Yeah, but I am also pretty sure that we don't do a good job prioritizing queries. For example, when you open the new project and ask for document symbobls, you have to wait until the whole project is processed, but, iirc, this needs only syntax.</p>
<p>I guess, in addition to fuel, we should have "weights", which allow us to selectively slow-down particular subsystems, to make sure that only relevant functionality is degraded, and not the whole server</p>



<a name="166171968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166171968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166171968">(May 21 2019 at 13:29)</a>:</h4>
<p>Am I right in remembering that we do not support the cancellation request? Is it possible that cancellation requests are coming through and we aren't processing them so things are getting backed up?</p>



<a name="166172257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172257">(May 21 2019 at 13:32)</a>:</h4>
<p>We don't support client-initiated cancellation, but I think it shouldn't be relevant</p>



<a name="166172285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172285">(May 21 2019 at 13:33)</a>:</h4>
<p>I've done some quick profiling and the picture I see is that chalk is sometimes quite slow</p>



<a name="166172311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172311">(May 21 2019 at 13:33)</a>:</h4>
<div class="codehilite"><pre><span></span>       2937ms - diagnostics
           2243ms - implements_query
</pre></div>



<a name="166172417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172417">(May 21 2019 at 13:34)</a>:</h4>
<p>There are also quite some queries  which take a loong time themselves, but don't have long deps listed</p>



<a name="166172438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172438">(May 21 2019 at 13:35)</a>:</h4>
<p>I <em>think</em> this is because thouse queries are actually blocked on that one slow chalk query</p>



<a name="166172492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172492">(May 21 2019 at 13:35)</a>:</h4>
<p><code>       8568ms - crate_def_map_query</code></p>



<a name="166172494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172494">(May 21 2019 at 13:35)</a>:</h4>
<p>is this normal?</p>



<a name="166172507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172507">(May 21 2019 at 13:35)</a>:</h4>
<p>For the initial load -- yeah</p>



<a name="166172532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172532">(May 21 2019 at 13:36)</a>:</h4>
<p><code>      11447ms - diagnostics</code></p>



<a name="166172632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172632">(May 21 2019 at 13:37)</a>:</h4>
<p>yeah, some Chalk queries can basically take arbitrarily long as long as we don't limit them</p>



<a name="166172721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172721">(May 21 2019 at 13:38)</a>:</h4>
<p>We probably want to add cancellation support to chalk at some point as well</p>



<a name="166172763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172763">(May 21 2019 at 13:38)</a>:</h4>
<p>... maybe we should just drive the chalk solver loop ourselves <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="166172793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172793">(May 21 2019 at 13:39)</a>:</h4>
<p>if we did, cancellation and fuel would be easy</p>



<a name="166172825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166172825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166172825">(May 21 2019 at 13:39)</a>:</h4>
<p>would this be enough?</p>
<p>Like, if the loop yields next solution, there can be arbitrary computations inside (nested loops, for example)</p>



<a name="166173083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173083">(May 21 2019 at 13:42)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> could you also create "chalk is slow" issue in the chalk repo? :-) You've looked into it way more than I did, so you should better understand what "slow" means.  I hope if we put this on the radar for the chalk developers, they'll come up with some nice optimizations :-)</p>



<a name="166173116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173116">(May 21 2019 at 13:42)</a>:</h4>
<p>they are usually fast, though, I think. I'm not very familiar with the details, but when it needs to solve a nested goal, it just does one step there and then returns a 'no results yet, might have more' error (<a href="https://github.com/rust-lang/chalk/blob/3238c6d0bc7d09b6eebe069ebd47dfabae787082/chalk-engine/src/logic.rs#L51" target="_blank" title="https://github.com/rust-lang/chalk/blob/3238c6d0bc7d09b6eebe069ebd47dfabae787082/chalk-engine/src/logic.rs#L51">https://github.com/rust-lang/chalk/blob/3238c6d0bc7d09b6eebe069ebd47dfabae787082/chalk-engine/src/logic.rs#L51</a>)</p>



<a name="166173165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173165">(May 21 2019 at 13:43)</a>:</h4>
<p>hm yeah, maybe I should try to reproduce some slow cases in the chalk test harness</p>



<a name="166173304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173304">(May 21 2019 at 13:45)</a>:</h4>
<p>Just to clarify, the slowness is due to chalk exploring some exponential search space, and not due to the fact that some simple optimizations (aka accidentally quadratic) are missing?</p>



<a name="166173357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173357">(May 21 2019 at 13:45)</a>:</h4>
<p>I think in general, they know this though -- it's what e.g. <a href="https://github.com/rust-lang/chalk/issues/217" target="_blank" title="https://github.com/rust-lang/chalk/issues/217">https://github.com/rust-lang/chalk/issues/217</a> and <a href="https://github.com/rust-lang/chalk/issues/80" target="_blank" title="https://github.com/rust-lang/chalk/issues/80">https://github.com/rust-lang/chalk/issues/80</a> are about</p>



<a name="166173379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173379">(May 21 2019 at 13:46)</a>:</h4>
<p>My guess would be that Chalk is really inefficient in searching some goals, instead of it getting too much input</p>



<a name="166173466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173466">(May 21 2019 at 13:46)</a>:</h4>
<p>Yeah, the non-enumerable goals problem is one where Chalk is looking at <code>Sized(?T)</code> first, which is a really bad search order</p>



<a name="166173472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173472">(May 21 2019 at 13:47)</a>:</h4>
<p>the cases I've seen are mostly that you have something like <code>where ?0: Foo, ?0: Send</code> and it tries enumerating every single type that implements <code>Send</code>, even though there might be just a few that implement <code>Foo</code>; or variations of that</p>



<a name="166173609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173609">(May 21 2019 at 13:48)</a>:</h4>
<p>which is exacerbated by us having lots of cases where there is no solution, so in our case <code>?0: Foo</code> might actually have no solution and it really tries to enumerate <em>all</em> types</p>



<a name="166173679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173679">(May 21 2019 at 13:49)</a>:</h4>
<p>Not sure if changing the ordering would help in that case</p>



<a name="166173764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173764">(May 21 2019 at 13:50)</a>:</h4>
<p>if we know that a certain clause has no solutions at all, we can immediately stop, right?</p>



<a name="166173837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166173837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166173837">(May 21 2019 at 13:51)</a>:</h4>
<p>Ah yes, it'll know whether <code>Foo</code> is implemented, and only search through the <code>Send</code> part if some of those impls depend on that</p>



<a name="166174441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166174441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hoang Luu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166174441">(May 21 2019 at 13:57)</a>:</h4>
<p>This seems similar to RDBMS's join problem, can we solve it same fashion? I.e. estimating number of impls per trait</p>



<a name="166174518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166174518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166174518">(May 21 2019 at 13:58)</a>:</h4>
<p>that's the direction that <a href="https://github.com/rust-lang/chalk/issues/80" target="_blank" title="https://github.com/rust-lang/chalk/issues/80">https://github.com/rust-lang/chalk/issues/80</a> goes in, I think</p>



<a name="166174658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166174658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166174658">(May 21 2019 at 13:59)</a>:</h4>
<p><a href="https://github.com/frankmcsherry/blog/blob/master/posts/2018-05-19.md#addendum-2018-05-21-treefrog-leapjoin" target="_blank" title="https://github.com/frankmcsherry/blog/blob/master/posts/2018-05-19.md#addendum-2018-05-21-treefrog-leapjoin">https://github.com/frankmcsherry/blog/blob/master/posts/2018-05-19.md#addendum-2018-05-21-treefrog-leapjoin</a> is an interesting read on the topic</p>



<a name="166174670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166174670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166174670">(May 21 2019 at 13:59)</a>:</h4>
<p>of joins</p>



<a name="166175134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166175134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166175134">(May 21 2019 at 14:03)</a>:</h4>
<p><a href="/user_uploads/4715/JWovhLE55EYjMxYwjtkl3z0D/pasted_image.png" target="_blank" title="pasted_image.png">pasted image</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/JWovhLE55EYjMxYwjtkl3z0D/pasted_image.png" target="_blank" title="pasted image"><img src="/user_uploads/4715/JWovhLE55EYjMxYwjtkl3z0D/pasted_image.png"></a></div>



<a name="166175139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166175139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166175139">(May 21 2019 at 14:03)</a>:</h4>
<p>ugh, so slow</p>



<a name="166175231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166175231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166175231">(May 21 2019 at 14:04)</a>:</h4>
<p>you're right I just flipped trace on and cancellation is pretty rare</p>



<a name="166175894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166175894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166175894">(May 21 2019 at 14:10)</a>:</h4>
<p>could running <code>cargo check</code> block typing (e.g. adding a newline) in RA?</p>



<a name="166176058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166176058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166176058">(May 21 2019 at 14:12)</a>:</h4>
<p>No I don't believe that it does. I've seen this happen with <code>cargo watch</code> disabled.</p>



<a name="166176088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166176088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166176088">(May 21 2019 at 14:12)</a>:</h4>
<p>As well as no issue when running <code>cargo check</code> while typing</p>



<a name="166176150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166176150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166176150">(May 21 2019 at 14:13)</a>:</h4>
<p>I just saw RA thinking that <code>cargo check</code> is running while it wasn't</p>



<a name="166176285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166176285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> memoryruins <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166176285">(May 21 2019 at 14:15)</a>:</h4>
<p>is ra_cli's <code>rust-analysis</code> a good way to bench parts of ra?</p>



<a name="166176329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166176329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> memoryruins <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166176329">(May 21 2019 at 14:15)</a>:</h4>
<p>ran valgrind massif and callgrind on top of it as it analyzed ra's repo an hour ago. looks like it captured a good bit of data. I won't be available to look closer until this afternoon though</p>



<a name="166176420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166176420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> memoryruins <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166176420">(May 21 2019 at 14:16)</a>:</h4>
<p>attaching a zip containing data and two screenshots (of kcachegrind and massif-visualizer) if anyone can make better use of them in the meantime <a href="/user_uploads/4715/fwzR1MaBEg83LAFCGsP1swU6/ra-massif-callgrind.zip" target="_blank" title="ra-massif-callgrind.zip">ra-massif-callgrind.zip</a></p>



<a name="166182689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166182689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166182689">(May 21 2019 at 15:25)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> Currently the toggling of animation about <code>cargo check</code> is just a simple string comparison to <code>'[Finished running'</code>. So maybe it fail to parse it. However, it should not related to this issue.</p>



<a name="166195085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166195085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166195085">(May 21 2019 at 17:45)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> did you intend to disable Chalk in <a href="https://github.com/rust-analyzer/rust-analyzer/commit/26463f189ff75e92990375ee5ae08d3903d39e66" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/commit/26463f189ff75e92990375ee5ae08d3903d39e66">https://github.com/rust-analyzer/rust-analyzer/commit/26463f189ff75e92990375ee5ae08d3903d39e66</a>?</p>



<a name="166196183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166196183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166196183">(May 21 2019 at 17:56)</a>:</h4>
<p>absolutelly nor</p>



<a name="166196277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166196277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166196277">(May 21 2019 at 17:57)</a>:</h4>
<p>that one time when you decide that it's fine to send a trivial PR without bors...</p>



<a name="166203787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166203787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> memoryruins <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166203787">(May 21 2019 at 19:20)</a>:</h4>
<p>ran <code>valgrind --tool=callgrind ~/projects/contribute/rust-analyzer/target/release/ra_cli analysis-stats</code> on a handful of crates, such as RA itself, cranelife, crossterm, and regex.</p>



<a name="166203793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166203793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> memoryruins <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166203793">(May 21 2019 at 19:21)</a>:</h4>
<p>for each project, <code>ra_parser::parser::Parser::nth</code> is calling a handful of functions from <code>ra_mbe::subtree_source</code> that make-up for the majority of instruction reads/calls, drastically outnumbering everything else <code>rust-analysis</code> is doing.</p>



<a name="166203814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166203814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> memoryruins <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166203814">(May 21 2019 at 19:21)</a>:</h4>
<p>tried <code>rust-analysis</code> on a fresh <code>cargo new &lt;crate&gt;</code> without any changes. it reported 696965 calls to <code>ra_mbe::subtree_source::SubTreeWalker::walk_token</code> from <code>WalkCursor::current</code>, 9689599 calls in <code>WalkerOwner::get</code> from within <code>is_token_joint_to_next</code>, 15248879 calls in <code>WalkerOwner::get</code> from within <code>&lt;ra_mbe::subtree_source::SubtreeTokenSource as ra_parser::TokenSource&gt;::token_kind</code> in an empty fresh project. running a <code>perf record</code> also has <code>ra_mbe::subtree_source::WalkerOwner::get</code> at the top of the list of overhead.</p>



<a name="166204942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166204942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> memoryruins <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166204942">(May 21 2019 at 19:32)</a>:</h4>
<p>disclaimer: today is the first time I've used callgrind, so although the above stood out, I might be missing something :)</p>



<a name="166205103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166205103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166205103">(May 21 2019 at 19:34)</a>:</h4>
<p>I think callgrind gives you precise statistic regarding the number of calls, but is not very precise when it comes to real time measurnments</p>



<a name="166206556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166206556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166206556">(May 21 2019 at 19:52)</a>:</h4>
<p>I assume that includes <code>rust-src</code>? Is the standard library code mbe-heavy?</p>



<a name="166206808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166206808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> memoryruins <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166206808">(May 21 2019 at 19:56)</a>:</h4>
<p>makes sense, the manual said to focus more on the instruction reads/Ir in the source view, but the above functions stood out in that regard too.</p>



<a name="166207007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%20is%20slow%20%3A-%28/near/166207007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> memoryruins <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.20is.20slow.20.3A-(.html#166207007">(May 21 2019 at 19:58)</a>:</h4>
<p><code>rust-src</code> sounds like a possibility. I need to look in what all <code>analysis-stats</code>as a command includes. noticed it used in another PR for a bench and rolled with it</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>